<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .div1{
            width: 100px;
            height: 100px;
            background: red;
            color: white;
            text-align: center;
            line-height: 100px;
            font-size: 30px;
            border-radius: 10px;
            margin: 200px auto 10px;
        }
        .div2{
            width: 100px;
            height: 100px;
            margin: 0 auto;
            text-align: center;
        }
    </style>
</head>
<body>

        <div class="div1" id="div1">
            未开始
        </div>
        <div class="div2">
            <button onclick="getname()">点名</button>
        </div>

        <script>
            var array = ["zs", "ls", "wu", "zl"];

            function getname() {
                if (array.length < 1){
                    alert("点名完毕, 刷新, 重新开始")
                    return;
                }
                var  index = Math.floor(Math.random() * array.length)


                var divNode = document.getElementById("div1")

                // 创建一个文本结点
                var textNode = document.createTextNode(array[index])

                divNode.replaceChild(textNode,  divNode.childNodes[0])

                array.splice(index, 1)
            }

        </script>
</body>
</html>
